import java.util.Vector;

public class evaluateBoard {

	 
	
	
	public static int getscore(Board board, PlayerNBoxes playerNBoxes,Vector<Position> targetsFB)
	{
	 	
		int score=0;
		Position[] boxes;
		
		boxes=playerNBoxes.getBoxes();
		Position[] targets;
		
		targets = new Position[targetsFB.size()];
		for ( int i = 0; i < targetsFB.size(); i++){
			targets[i] = targetsFB.elementAt(i);
			
		}
		
		//move from x1,y1 to x2,y2  
		int distance=0;
		int min=0;
		int[] min_distance=new int[targets.length];  //reusable variables ...
		
		for (int i=0; i<targets.length;i++)
		{
			
			for (int j=0;j<boxes.length; j++)
			{
              
			  distance=getDistance(targets[i],boxes[j]);
			  if(i==0 || distance<min)
			  {
				  min=distance;
			  }
			  
			}
			min_distance[i]=min;
		    score+=min;
		   
		
		}
	   
		
		
	 	return score;
	 	
	}
    
	private static int getDistance(Position target, Position box)
	{
		int distance=0;
		
		distance= Math.abs(box.getX()-target.getX()) + Math.abs(box.getY()-target.getY());
		// once the move_box function is ready ... we will get this running ...
		//player moves ..
		
		return distance;
	}
	
    
    
    
    
}
